<?php
$db =  require 'basepdo.php';
//pdo的最大的特点就是引入了参数绑定和预编译,参数绑定和预编译是什么关系，其实二者是同一件事的不同阶段
//pdo参数绑定示例
$id = 300;
$client_status = 1;
$sth = $db->prepare('SELECT id,client_name,client_abbre FROM bd_client 
WHERE id < :id AND client_status = :client_status ORDER BY id DESC LIMIT 300
');

//绑定一个PHP变量到一个预处理语句的参数中
$sth->bindParam(':id',$id,PDO::PARAM_INT);
$sth->bindParam(':client_status',$client_status,PDO::PARAM_INT);
//绑定好之后就执行
$sth->execute();

//var_dump($sth->fetchAll(PDO::FETCH_ASSOC));


$new_sth = $db->prepare('SELECT id,client_name,client_abbre FROM bd_client WHERE id < ? AND client_status = ?');
$new_sth->bindParam(1,$id,PDO::PARAM_INT);
$new_sth->bindParam(2,$client_status,PDO::PARAM_INT,12);
$new_sth->execute();
var_dump($new_sth->fetchAll(PDO::FETCH_ASSOC));


